<?php
namespace app\admin\controller;
use think\Controller;
//引入数据库操作文件
use think\Db;
use think\Session;
class Login extends Controller {
	public function login() {
		$err = "";
		$this -> assign("err", $err);
		return $this -> fetch("login/login");
	}
	/*
	 登录
	 * */
	function logininfo() {
		if (!empty($_POST)) {
			$name = $_POST['userName'];
			$pwd = md5($_POST['password']);
			
			$result = Db::name('admin') -> where("adminname='" . $name . "' and adminpwd='" . $pwd . "'") -> find();
			$rs = $result['adminid'];
			if (count($result) > 0) {
				Session::set('login_admin', $rs);
				$this -> assign("err", 1);
				return $this -> fetch('login/login');
			} else {
				$this -> assign("err", 2);
				return $this -> fetch('login/login');
			}
		}

	}

}
?>